<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{html_select_date}</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="language.custom.functions.html" title="Chapter 8. Custom Functions">
<link rel="prev" href="language.function.html.radios.html" title="{html_radios}">
<link rel="next" href="language.function.html.select.time.html" title="{html_select_time}">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">{html_select_date}</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.function.html.radios.html">Prev</a> </td>
<th width="60%" align="center">Chapter 8. Custom Functions</th>
<td width="20%" align="right"> <a accesskey="n" href="language.function.html.select.time.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="{html_select_date}">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="language.function.html.select.date"></a>{html_select_date}</h2></div></div></div>
<p>
   <code class="varname">{html_select_date}</code> is a
   <a class="link" href="language.custom.functions.html" title="Chapter 8. Custom Functions">custom function</a>
   that creates date dropdowns.
   It can display any or all of year, month, and day.
  All parameters that are not in the list below are printed as
  name/value-pairs inside the <code class="literal">&lt;select&gt;</code> tags
  of day, month and  year.
 </p>
<div class="informaltable"><table border="1">
<colgroup>
<col align="center">
<col align="center">
<col align="center">
<col align="center">
<col>
</colgroup>
<thead><tr>
<th align="center">Attribute Name</th>
<th align="center">Type</th>
<th align="center">Required</th>
<th align="center">Default</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td align="center">prefix</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">Date_</td>
<td>What to prefix the var name with</td>
</tr>
<tr>
<td align="center">time</td>
<td align="center">
      <a class="ulink" href="http://php.net/function.time" target="_top">timestamp</a>, 
      <a class="ulink" href="http://php.net/class.DateTime" target="_top">DateTime</a>, 
      mysql timestamp or any string parsable by 
      <a class="ulink" href="http://php.net/strtotime" target="_top"><code class="varname">strtotime()</code></a>, 
      arrays as produced by this function if field_array is set.
     </td>
<td align="center">No</td>
<td align="center">current <a class="ulink" href="http://php.net/function.time" target="_top">timestamp</a>
</td>
<td>
      What date/time to pre-select. If an array is given, the attributes field_array and prefix 
      are used to identify the array elements to extract year, month and day from.
     </td>
</tr>
<tr>
<td align="center">start_year</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">current year</td>
<td>The first year in the dropdown, either
      year number, or relative to current year (+/- N)</td>
</tr>
<tr>
<td align="center">end_year</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">same as start_year</td>
<td>The last year in the dropdown, either
      year number, or relative to current year (+/- N)</td>
</tr>
<tr>
<td align="center">display_days</td>
<td align="center">boolean</td>
<td align="center">No</td>
<td align="center"><code class="constant">TRUE</code></td>
<td>Whether to display days or not</td>
</tr>
<tr>
<td align="center">display_months</td>
<td align="center">boolean</td>
<td align="center">No</td>
<td align="center"><code class="constant">TRUE</code></td>
<td>Whether to display months or not</td>
</tr>
<tr>
<td align="center">display_years</td>
<td align="center">boolean</td>
<td align="center">No</td>
<td align="center"><code class="constant">TRUE</code></td>
<td>Whether to display years or not</td>
</tr>
<tr>
<td align="center">month_format</td>
<td align="center">array</td>
<td align="center">No</td>
<td align="center">null</td>
<td>List of strings to display for months. array(1 =&gt; 'Jan', …, 12 =&gt; 'Dec')</td>
</tr>
<tr>
<td align="center">month_names</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">%B</td>
<td>What format the month should be in (strftime)</td>
</tr>
<tr>
<td align="center">day_format</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">%02d</td>
<td>What format the day output should be in (sprintf)</td>
</tr>
<tr>
<td align="center">day_value_format</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">%d</td>
<td>What format the day value should be in (sprintf)</td>
</tr>
<tr>
<td align="center">year_as_text</td>
<td align="center">boolean</td>
<td align="center">No</td>
<td align="center"><code class="constant">FALSE</code></td>
<td>Whether or not to display the year as text</td>
</tr>
<tr>
<td align="center">reverse_years</td>
<td align="center">boolean</td>
<td align="center">No</td>
<td align="center"><code class="constant">FALSE</code></td>
<td>Display years in reverse order</td>
</tr>
<tr>
<td align="center">field_array</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>
      If a name is given, the select boxes will be drawn
      such that the results will be returned to PHP in the
      form of name[Day], name[Year], name[Month].
     </td>
</tr>
<tr>
<td align="center">day_size</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds size attribute to select tag if given</td>
</tr>
<tr>
<td align="center">month_size</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds size attribute to select tag if given</td>
</tr>
<tr>
<td align="center">year_size</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds size attribute to select tag if given</td>
</tr>
<tr>
<td align="center">all_extra</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds extra attributes to all select/input tags if given</td>
</tr>
<tr>
<td align="center">day_extra</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds extra attributes to select/input tags if given</td>
</tr>
<tr>
<td align="center">month_extra</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds extra attributes to select/input tags if given</td>
</tr>
<tr>
<td align="center">year_extra</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds extra attributes to select/input tags if given</td>
</tr>
<tr>
<td align="center">all_id</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds id-attribute to all select/input tags if given</td>
</tr>
<tr>
<td align="center">day_id</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds id-attribute to select/input tags if given</td>
</tr>
<tr>
<td align="center">month_id</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds id-attribute to select/input tags if given</td>
</tr>
<tr>
<td align="center">year_id</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>Adds id-attribute to select/input tags if given</td>
</tr>
<tr>
<td align="center">field_order</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">MDY</td>
<td>The order in which to display the fields</td>
</tr>
<tr>
<td align="center">field_separator</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">\n</td>
<td>String printed between different fields</td>
</tr>
<tr>
<td align="center">month_value_format</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">%m</td>
<td>strftime() format of the month values, default is
      %m for month numbers.</td>
</tr>
<tr>
<td align="center">all_empty</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>If supplied then the first element of any select-box has this
     value as it's label and <span class="quote">“<span class="quote"></span>”</span> as it's value. This is useful to make the
     select-boxes read <span class="quote">“<span class="quote">Please select</span>”</span> for example.</td>
</tr>
<tr>
<td align="center">year_empty</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>If supplied then the first element of the year's select-box has this
     value as it's label and <span class="quote">“<span class="quote"></span>”</span> as it's value. This is useful to make the
     select-box read <span class="quote">“<span class="quote">Please select a year</span>”</span> for example.
     Note that you can use values like <span class="quote">“<span class="quote">-MM-DD</span>”</span> as time-attribute to indicate
     an unselected year.</td>
</tr>
<tr>
<td align="center">month_empty</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>If supplied then the first element of the month's select-box has this
     value as it's label and <span class="quote">“<span class="quote"></span>”</span> as it's value. .
     Note that you can use values like <span class="quote">“<span class="quote">YYYY--DD</span>”</span> as time-attribute to indicate
     an unselected month.</td>
</tr>
<tr>
<td align="center">day_empty</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center">null</td>
<td>If supplied then the first element of the day's select-box has this
     value as it's label and <span class="quote">“<span class="quote"></span>”</span> as it's value.
     Note that you can use values like <span class="quote">“<span class="quote">YYYY-MM-</span>”</span> as
     time-attribute to indicate  an unselected day.</td>
</tr>
</tbody>
</table></div>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
   There is an useful php function on the
   <a class="link" href="tips.dates.html" title="Dates">date tips page</a> for converting
   <code class="varname">{html_select_date}</code> form values to a timestamp.
  </p>
</div>
<div class="example">
<a name="id400198"></a><p class="title"><b>Example 8.16. {html_select_date}</b></p>
<div class="example-contents">
<p>Template code</p>
<pre class="programlisting">

{html_select_date}

  </pre>
<p>
   This will output:
  </p>
<pre class="screen">

&lt;select name="Date_Month"&gt;
&lt;option value="1"&gt;January&lt;/option&gt;
&lt;option value="2"&gt;February&lt;/option&gt;
&lt;option value="3"&gt;March&lt;/option&gt;
  ..... snipped .....
&lt;option value="10"&gt;October&lt;/option&gt;
&lt;option value="11"&gt;November&lt;/option&gt;
&lt;option value="12" selected="selected"&gt;December&lt;/option&gt;
&lt;/select&gt;
&lt;select name="Date_Day"&gt;
&lt;option value="1"&gt;01&lt;/option&gt;
&lt;option value="2"&gt;02&lt;/option&gt;
&lt;option value="3"&gt;03&lt;/option&gt;
  ..... snipped .....
&lt;option value="11"&gt;11&lt;/option&gt;
&lt;option value="12"&gt;12&lt;/option&gt;
&lt;option value="13" selected="selected"&gt;13&lt;/option&gt;
&lt;option value="14"&gt;14&lt;/option&gt;
&lt;option value="15"&gt;15&lt;/option&gt;
  ..... snipped .....
&lt;option value="29"&gt;29&lt;/option&gt;
&lt;option value="30"&gt;30&lt;/option&gt;
&lt;option value="31"&gt;31&lt;/option&gt;
&lt;/select&gt;
&lt;select name="Date_Year"&gt;
&lt;option value="2006" selected="selected"&gt;2006&lt;/option&gt;
&lt;/select&gt;

  </pre>
</div>
</div>
<br class="example-break"><div class="example">
<a name="id400224"></a><p class="title"><b>Example 8.17. {html_select_date} second example</b></p>
<div class="example-contents">
<pre class="programlisting">

{* start and end year can be relative to current year *}
{html_select_date prefix='StartDate' time=$time start_year='-5'
   end_year='+1' display_days=false}

  </pre>
<p>
   With  2000 as the current year the output:
  </p>
<pre class="screen">

&lt;select name="StartDateMonth"&gt;
&lt;option value="1"&gt;January&lt;/option&gt;
&lt;option value="2"&gt;February&lt;/option&gt;
.... snipped ....
&lt;option value="11"&gt;November&lt;/option&gt;
&lt;option value="12" selected="selected"&gt;December&lt;/option&gt;
&lt;/select&gt;
&lt;select name="StartDateYear"&gt;
&lt;option value="1995"&gt;1995&lt;/option&gt;
.... snipped ....
&lt;option value="1999"&gt;1999&lt;/option&gt;
&lt;option value="2000" selected="selected"&gt;2000&lt;/option&gt;
&lt;option value="2001"&gt;2001&lt;/option&gt;
&lt;/select&gt;

  </pre>
</div>
</div>
<br class="example-break"><p>
  See also
  <a class="link" href="language.function.html.select.time.html" title="{html_select_time}"><code class="varname">{html_select_time}</code></a>,
  <a class="link" href="language.modifier.date.format.html" title="date_format"><code class="varname">date_format</code></a>,
  <a class="link" href="language.variables.smarty.html#language.variables.smarty.now" title="{$smarty.now}"><em class="parameter"><code>$smarty.now</code></em></a>
  and the <a class="link" href="tips.dates.html" title="Dates">date tips page</a>.
 </p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.function.html.radios.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="language.custom.functions.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="language.function.html.select.time.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">{html_radios} </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> {html_select_time}</td>
</tr>
</table>
</div>
</body>
</html>
